<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="utf-8">
    <title>utils/cartesian2d.js - Documentation</title>
    
    
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
    <script src="scripts/nav.js" defer></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav >
    
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-$ui_charts_my-chart.html">$ui/charts/my-chart</a></li></ul><h3>Global</h3><ul><li><a href="global.html#baseSeries">baseSeries</a></li><li><a href="global.html#columnsToStandard">columnsToStandard</a></li><li><a href="global.html#createAxis">createAxis</a></li><li><a href="global.html#createDataset">createDataset</a></li><li><a href="global.html#createDimensions">createDimensions</a></li><li><a href="global.html#createPieSeries">createPieSeries</a></li><li><a href="global.html#createSeries">createSeries</a></li><li><a href="global.html#createSource">createSource</a></li><li><a href="global.html#DEFAULT_THEME">DEFAULT_THEME</a></li><li><a href="global.html#formatValue">formatValue</a></li><li><a href="global.html#getDataByLevel">getDataByLevel</a></li><li><a href="global.html#getLabelConfig">getLabelConfig</a></li><li><a href="global.html#getLabelFormatter">getLabelFormatter</a></li><li><a href="global.html#getLevelPieRadius">getLevelPieRadius</a></li><li><a href="global.html#getLimitRows">getLimitRows</a></li><li><a href="global.html#getNeedTransformColumnIndexes">getNeedTransformColumnIndexes</a></li><li><a href="global.html#getStackName">getStackName</a></li><li><a href="global.html#injectLabel">injectLabel</a></li><li><a href="global.html#PIE_LABEL_LINE">PIE_LABEL_LINE</a></li><li><a href="global.html#PIE_ROSE_ITEM_STYLE">PIE_ROSE_ITEM_STYLE</a></li><li><a href="global.html#props">props</a></li><li><a href="global.html#SERIES_LABEL_POSITION">SERIES_LABEL_POSITION</a></li><li><a href="global.html#transformData">transformData</a></li></ul>
</nav>

<div id="main">
    
    <h1 class="page-title">utils/cartesian2d.js</h1>
    

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>import {cloneDeep} from '$ui/utils/util'
import {columnsToStandard, createDataset} from '$ui/charts/utils/dataset'
import factory from '$ui/charts/utils/factory'
import {createAxis} from '$ui/charts/utils/axis'
import {createSeries} from '$ui/charts/utils/series'
import setExtend from '$ui/charts/utils/extend'

/**
 * 构建二维的直角坐标系图表options，line 或 bar
 * @param data
 * @param settings
 * @param options
 * @param type
 * @param props
 */
export default function ({data, settings}, type, props) {
  // 克隆数据
  const dataCopy = cloneDeep(data)

  // 转换成标准的列配置
  const standardColumns = columnsToStandard(dataCopy)

  // 获取私有配置的值
  const settingsValue = factory(props, settings)

  // 构建dataset
  const dataset = createDataset(standardColumns, dataCopy, settingsValue)

  // 构建轴配置
  const axis = createAxis(settingsValue, dataset)

  // 构建系列
  const series = createSeries({
    type: type,
    layout: dataCopy.layout,
    dimensions: dataset.dimensions,
    settings: settingsValue
  })

  // 原生 option
  const options = {
    tooltip: {},
    legend: {},
    ...axis,
    series: series,
    dataset: dataset
  }

  // 扩展配置
  setExtend(options, {
    series: {
      smooth: settingsValue.smooth
    },
    xAxis: {
      boundaryGap: true,
      axisTick: {
        alignWithLabel: true
      }
    },
    yAxis: {
      boundaryGap: true,
      axisTick: {
        alignWithLabel: true
      }
    }
  })

  return options
}
</code></pre>
        </article>
    </section>





    
</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a> on Wed Jun 10 2020 17:09:12 GMT+0800 (GMT+08:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>




<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>
</html>
